package com.zc.servicebase.exception;

import com.zc.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@Slf4j
public class GlobalException extends Exception{
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public R error(Exception e) {
		log.error(e.getMessage());
        return R.error().message(e.getMessage());
	}

	@ExceptionHandler(CongException.class)
	@ResponseBody
	public R error(CongException e) {
		log.error(e.getMessage());
		return R.error().message(e.getMessage());
	}
}
